package com.vpen.client.test;

import lombok.extern.slf4j.Slf4j;
import org.springframework.messaging.simp.stomp.StompCommand;
import org.springframework.messaging.simp.stomp.StompHeaders;
import org.springframework.messaging.simp.stomp.StompSession;
import org.springframework.messaging.simp.stomp.StompSessionHandlerAdapter;

import java.lang.reflect.Type;

/**
 * 描述
 *
 * @author 韦鹏
 * @date 2022/11/28 14:11
 */
@Slf4j
public class MyStompSessionHandler extends StompSessionHandlerAdapter {

    @Override
    public Type getPayloadType(StompHeaders headers) {
        log.debug("getPayloadType:{}", headers);
        return super.getPayloadType(headers);
    }

    @Override
    public void handleFrame(StompHeaders headers, Object payload) {
        log.debug("接受到订阅的消息：{}", payload);
    }

    @Override
    public void afterConnected(StompSession session, StompHeaders connectedHeaders) {
        log.debug("连接后....");
    }

    @Override
    public void handleException(StompSession session,
                                StompCommand command,
                                StompHeaders headers,
                                byte[] payload,
                                Throwable exception) {
        log.error("出现错误");
    }

    @Override
    public void handleTransportError(StompSession session, Throwable exception) {
        log.error("转换错误");
    }
}
